#include <iostream>
#include "image2d_ptr.h"
#include "cvtColor.h"
#include "imageFile.h"

int ff(Image2D::Image2D_Ptr& im)
{
    Image2D::Image2D_Ptr imageRgb;
    Image2D::imageReadToRgb("./girl.jpeg", imageRgb);
    im = imageRgb;

    return 0;
}

int main()
{
    Image2D::Image2D_Ptr imageYuv420p;
    int ret = Image2D::imageReadToYuv420p("./girl.jpeg", imageYuv420p);
    if (ret != 0)
    {
        std::cout << Image2D::Image2D_Ptr::lastErrorStr() << std::endl;
    }

    Image2D::Image2D_Ptr imageNv12(imageYuv420p.width(), imageYuv420p.height(), Image2D::ImageFormat::IMAGE_NV12, Image2D::ImageType::IMAGE_UNSIGNED_CHAR);
    Image2D::yuv420pToNv12(imageYuv420p, imageNv12);
    ret = Image2D::lastErrorCode();
    if (ret != 0)
    {
        std::cout << Image2D::Image2D_Ptr::lastErrorStr() << std::endl;
    }

    ret = Image2D::imageWriteJpegFromNv12("./girl1.jpeg", imageNv12);
    if (ret != 0)
    {
        std::cout << Image2D::Image2D_Ptr::lastErrorStr() << std::endl;
    }

    return 0;
}